package com.xd.util;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName WebConfig
 * @Description TODO
 * @Author Dell
 * @Date 2025/6/24
 **/
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOriginPatterns("*")         // ✅ 改这里！支持与 credentials 共存
                .allowedMethods("*")
                .allowedHeaders("*")
                .allowCredentials(true);            // ✅ 支持携带 Cookie / 认证头等
    }
}

